package org.xukai.core.aop.springaop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.quartz.Scheduler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class AopInterceptor implements Ordered
{
	@Autowired
	private Scheduler scheduler;


	@Pointcut("execution(public * com.dexcoder.demo.service.impl..*.*(..))")
	public void myMethod(){}
	
	@Before("execution(public * com.dexcoder.demo.service.impl..*.*aop(..))")
	public void beforeMethod()
	{
		System.out.println("+++++"+scheduler);
		System.out.println("save start......");
	}
	
	@AfterReturning("execution(public * com.dexcoder.demo.service.impl..*.*(..))")
	public void afterReturnning()
	{
		System.out.println("after save......");
	}
	
	@AfterThrowing("myMethod()")
	public void afterThrowing()
	{
		System.out.println("after throwing......");
	}

	@Override
	public int getOrder() {
		return 0;
	}

	@Around("myMethod()")
	public void aroundMethod(ProceedingJoinPoint pjp) throws Throwable
	{
		System.out.println("method around start!");
		pjp.proceed();
		System.out.println("method around end!");
	}
}
